#ifndef CANCONFIG_h
#define CANCONFIG_h

#include "controlcan.h"
#include "std_msgs/msg/int32.hpp"
#include "signal.h"
#include <sstream>
#include <iomanip>
#include <pthread.h>

// 动作消息 F:正转 R:反转
BYTE joint_stop[4] = {0x0e, 0x80, 0x80, 0x80};
BYTE joint_move[4] = {0x0e, 0x80, 0x80, 0x80};

BYTE joint1_f[4] = {0x8e, 0x80, 0x80, 0x80};
BYTE joint1_r[4] = {0x4e, 0x80, 0x80, 0x80};
BYTE joint_move1[4] = {0x0e, 0x80, 0x80, 0x80};




BYTE joint2_f[4] = {0x0e, 0x81, 0x80, 0x80};
BYTE joint2_r[4] = {0x0e, 0x55, 0x80, 0x80};
BYTE joint_move2[4] = {0x0e, 0x80, 0x80, 0x80};


BYTE joint3_f[4] = {0x0e, 0x80, 0x81, 0x80};
BYTE joint3_r[4] = {0x0e, 0x80, 0x7f, 0x80};
BYTE joint_move3[4] = {0x0e, 0x80, 0x80, 0x80};

BYTE joint4_f[4] = {0x0e, 0x80, 0x80, 0x81};
BYTE joint4_r[4] = {0x0e, 0x80, 0x80, 0x7f};

// 编码器的设置

VCI_CAN_OBJ joint_encoder;
VCI_CAN_OBJ rec[3000]; // 接收长度
UINT Len = 5;   
INT WaitTime = 1000; // 等待时间
uint8_t receiveData[4];
uint8_t realData[2];



// USB-CAN系列接口卡的设备信息
VCI_BOARD_INFO board_info;
// 初始化CAN的配置
VCI_INIT_CONFIG init_config;
// CAN帧结构体
VCI_CAN_OBJ send_joint_v;
// can id
int joint_id = 0x0c0ac2c3;
int action_flag;
// 设备类型修改
DWORD device_type;
// 设备的索引
DWORD device_index;
// CAN控制器的索引 CAN1为0，CAN2为1
DWORD can_index;
// 函数声明
void Init_Can(void);
void SendData(VCI_CAN_OBJ &handle_obj, const int id, const BYTE *data, int dataLen);
void *receive_func(void *param);

#endif